package com.service.admin.base.controller;

import com.service.admin.base.controller.rep.CoinsRep;
import com.service.admin.base.controller.req.BannerSaveReq;
import com.service.admin.base.controller.req.CoinSaveReq;
import com.service.admin.base.service.CoinService;
import com.service.admin.framework.log.RequestLog;
import com.service.core.rest.BaseController;
import com.service.core.rest.response.BaseResponse;
import com.service.core.rest.response.MultiResponse;
import com.service.core.rest.response.OneResponse;
import com.service.dao.model.Coins;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController()
@Api(tags = "币种相关")
@RequestMapping("coins")
public class CoinController extends BaseController {

    @Autowired
    private CoinService coinService;

    @ApiOperation("币种信息配置")
    @RequestLog("币种信息配置")
    @PostMapping("list")
    public MultiResponse<CoinsRep> list(){
        return successQueryMultiResponse(coinService.getCoins());
    }

    @RequestLog("添加")
    @PostMapping("/add")
    public BaseResponse add(@RequestBody CoinSaveReq coinSaveReq) throws Exception {
        coinService.add(coinSaveReq);
        return successSaveBaseResponse();
    }

    @RequestLog("更新")
    @PostMapping("/update")
    public BaseResponse update(@RequestBody CoinSaveReq coinSaveReq) {
        coinService.update(coinSaveReq);
        return successSaveBaseResponse();
    }

    @RequestLog("详情")
    @PostMapping("/detail/{id}")
    public OneResponse<Coins> detail(@PathVariable("id") Integer id) {
        return successQueryOneResponse(coinService.getById(id));
    }

}
